<style lang="less" scoped>
.my-cancel {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  background-color: #f2f2f2;

  .cancel-container {
    width: 100%;
    height: 100%;
    position: absolute;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    .cancel-img {
      text-align: center;
      padding-top: 197px;
      img {
        width: 298px;
        height: 282px;
      }
    }
    .cancel-footer {
      width: 100%;
      padding: 76px 76px 0 74px;
      .cancel-binding {
        height: 96px;
        background: #536dfe;
        box-shadow: 0 5px 24px 0 rgba(83, 109, 254, 0.44);
        border-radius: 16px;
        font-size: 36px;
        color: #ffffff;
        width: 100%;
      }
    }
  }
}
</style>

<template>
  <div class="my-cancel">
    <!-- <Header return-color="#536DFE">
      <span slot="title">{{ (type==1?'微信号':'') || (type==2?'QQ':'') || (type==3?'钉钉':'') }}绑定</span>
    </Header> -->

    <div class="cancel-container">
      <div class="cancel-img">
        <img
          v-if="type==0"
          src="../../assets/weixin.png"
        >
        <img
          v-if="type==1"
          src="../../assets/qq.png"
        >
        <img
          v-if="type==2"
          src="../../assets/dingding.png"
        >
      </div>

      <div class="cancel-footer">
        <button class="cancel-binding" @tap="cancelBind()">
          取消绑定
        </button>
      </div>
    </div>
  </div>
</template>

<script>
import {cancelBind} from '../../actions/my';
// import { pageContainer } from '@/helper/plugin';

export default {
  name: 'MyCancel',
  data() {
    return {
      type: 0,
    };
  },
  created() {},
  mounted() {
    const currentWeb = plus.webview.currentWebview();
    // pageContainer('cancel-container');
    this.type = currentWeb.type-1;
  },
  methods: {
    async cancelBind(){
      const me = this;
      const type = me.type;
      const typeArr = ['weixin','qq','dt'];
      const resData = await cancelBind({
        type:typeArr[type]
      })
      if(resData.success){
        mui.toast(resData.obj);
        setTimeout(() => {
          const parent = plus.webview.currentWebview().opener();
          mui.fire(parent, 'backParent');
          mui.back();
        }, 1000);
      }else{
        mui.toast('取消失败');
      }
    }
  },
};
</script>
